import React, {
    lazy,
    Suspense
} from "react";
import {useRoutes} from "react-router-dom";

const lazyLoading = (comPath:string) => {
    const Com = lazy(()=>import("@/pages/"+comPath))
    return (
        <Suspense fallback={<h3>加载中……</h3>}>
            <Com/>
        </Suspense>
    )
}
export default function () {
    return useRoutes([
        {
            path: "/",
            element: lazyLoading("Index")
        }, {
            path: "/login",
            element:lazyLoading("Login")
        }, {
            path: "*",
            element:lazyLoading("NotFound")
        }
    ])
}
